//
//  TOAddPicViewController.m
//  X-Tribe
//
//  Created by Miss.Ou on 16/4/6.
//  Copyright © 2016年 Miss.Ou. All rights reserved.
//

#import "TOAddPicViewController.h"
#import "TOAddPicView.h"

@interface TOAddPicViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate,UIPickerViewDelegate
>

@end

@implementation TOAddPicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    //添加显示图片的相册控件
    [self setupPhotosView];
}
// 添加显示图片的相册控件
-(void)setupPhotosView
{
    TOAddPicView *photosView = [[TOAddPicView alloc]init];
    photosView.backgroundColor = [UIColor whiteColor];
    photosView.width = self.view.width;
    photosView.height = self.view.height;
    photosView.y = 70;
    photosView.x = 0;
    [self.view addSubview:photosView];
    self.view = photosView;
    
}

//打开照相机
-(void)openCamera
{
    if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) return;
    
    
    UIImagePickerController *ipc = [[UIImagePickerController alloc]init];
    ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
    
    ipc.delegate = self;
    
    [self presentViewController:ipc animated:YES completion:nil];
    
}

//打开相册
-(void)openAlbum
{
    if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        return;
    }
    UIImagePickerController *ipc = [[UIImagePickerController alloc]init];
    ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    
    ipc.delegate = self;
    
    [self presentViewController:ipc animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
